import { getXnxqList } from '../../../utils/util'
const xnxqList = getXnxqList()
Page({
  data: {
    classFreeListenData: [
      {
        name: '大学英语',
        id: '154623486654',
        time: '2018-12-16 17:00'
      },
      {
        name: '计算机基础',
        id: '154623486654',
        time: '2018-12-16 17:00'
      },
      {
        name: '体育',
        id: '154623486654',
        time: '2018-12-16 17:00'
      },
      {
        name: '毛概理论',
        id: '154623486654',
        time: '2018-12-16 17:00'
      },
      {
        name: '大学英语',
        id: '154623486654',
        time: '2018-12-16 17:00'
      },
      {
        name: '计算机基础',
        id: '154623486654',
        time: '2018-12-16 17:00'
      }
    ],
    yearTerm: getXnxqList(true),
    index: xnxqList.length - 1,
    xnxqList,
    bIsPopupShow: false, // 是否显示 “申请免听” 弹窗
    beginYear: '2019',
    beginMonth: '09',
    beginDay: '10',
    endYear: '2019',
    endMonth: '09',
    endDay: '10',
    beginDate: '2019-09-10', // 开始时间
    endDate: '2019-09-10' // 结束时间
  },
  goRecordList() {
    wx.navigateTo({
      url: '/pages/workService/recordList1/index'
    })
  },
  /**
   * @see 点击选择下拉学年学期
   */
  bindPickerChange (e) {
    this.setData({
      index: e.detail.value
    })
  },
  /**
   * @see 点击"申请免听"
   */
  applyFreeListen (e) {
    console.log('点击免听', e)
    this.setData({
      bIsPopupShow: true
    })
  },
  /**
   * @see 点击弹窗"取消"
   */
  handCancel () {
    this.setData({
      bIsPopupShow: false
    })
  },
  /**
   * @see 点击弹窗"提交"
   */
  handleConfirm () {
    this.setData({
      bIsPopupShow: false
    })
  },
  /**
   * @see 点击弹窗"开始时间"
   */
  bindBeginDateChange (e) {
    const date = e.detail.value
    this.setData({
      beginDate: date,
      beginYear: date.substring(0, 4),
      beginMonth: date.substring(5, 7),
      beginDay: date.substring(8, 10)
    })
  },
  /**
   * @see 点击弹窗"结束时间"
   */
  bindEndDateChange (e) {
    const date = e.detail.value
    this.setData({
      endDate: date,
      endYear: date.substring(0, 4),
      endMonth: date.substring(5, 7),
      endDay: date.substring(8, 10)
    })
  },
  /**
   * @see 点击“添加附件”
   */
  addFile () {
    wx.chooseMessageFile({
      count: 10,
      type: 'all',
      success (res) {
        // tempFilePath可以作为img标签的src属性显示图片
        const tempFilePaths = res.tempFilePaths
        console.log(tempFilePaths)
      }
    })
  }
})